package ac.github.os.internal.core.holder

import ac.github.os.api.common.entity.EntityAdapter
import org.bukkit.entity.LivingEntity
import org.bukkit.event.Event

abstract class EntityCompatible<T : Event> : EventHolder<T> {

    abstract fun entity(): EntityAdapter

    override fun variable(string: String): String {
        val entity = entity()
        return when (string) {
            "entity:name" -> entity.displayName
            "entity:type" -> entity.type.name
            else -> string
        }
    }

    fun LivingEntity.adapt(): EntityAdapter {
        return EntityAdapter(uniqueId.toString(), type, name)
    }

}